#include <algorithm>
#include <iostream>
#include <string>
#define LL long long
using namespace std;

const int kMaxN = 1e5 + 10;
const LL kInf = 1e18;

int c[kMaxN];
string s[kMaxN], rev_s[kMaxN];
LL f[kMaxN][2];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    rev_s[i] = s[i];
    reverse(rev_s[i].begin(), rev_s[i].end());
  }
  f[0][0] = 0;
  f[0][1] = c[0];
  for (int i = 1; i < n; i++) {
    f[i][0] = f[i][1] = kInf;
    if (s[i - 1] <= s[i]) {
      f[i][0] = min(f[i][0], f[i - 1][0]);
    }
    if (s[i - 1] <= rev_s[i]) {
      f[i][1] = min(f[i][1], f[i - 1][0] + c[i]);
    }
    if (rev_s[i - 1] <= s[i]) {
      f[i][0] = min(f[i][0], f[i - 1][1]);
    }
    if (rev_s[i - 1] <= rev_s[i]) {
      f[i][1] = min(f[i][1], f[i - 1][1] + c[i]);
    }
  }
  LL ans = min(f[n - 1][0], f[n - 1][1]);
  cout << (ans == kInf ? -1 : ans) << "\n";
  return 0;
}